<template>
  <div>
    <div>
      <ul>
        <li v-for="(item, index) in arr" :key="item">
          <span>{{ item }}</span>
          <button @click="Del(index)">删除</button>
        </li>
      </ul>
    </div>

    <button @click="Add">生成</button>
  </div>
</template>

<script>
export default {
  data() {
    return {
      arr: [10, 9, 8],
    };
  },
  methods: {
    Add() {
      //随机数生成
      this.arr.push(Math.floor(Math.random() * 10));
    },
    Del(index) {
      this.arr.splice(index, 1);
    },
  },
};
</script>

<style>
</style>